/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.playground.core.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * This class does not represent an instance of a game to be played, it should
 * not contain rules nor mechanics. GameTitle represents just the attributes
 * related to a title, like name, launch date and the number of times it was
 * played.
 * 
 * @author Tiago Peres
 */
@Entity
public class GameTitle implements Serializable {
    @Id
    @GeneratedValue
    private long id;
    
    @Temporal(TemporalType.TIMESTAMP)
    private Date launchDate;
    
    private int maximumNumberOfPlayers;
    @Column(unique = true)
    private String name;
    private int playedTimes;
    private int rating; // varies from 1 to 5

    public Date getLaunchDate() {
        return launchDate;
    }

    public void setLaunchDate(Date launchDate) {
        this.launchDate = launchDate;
    }

    public int getMaximumNumberOfPlayers() {
        return maximumNumberOfPlayers;
    }

    public void setMaximumNumberOfPlayers(int maximumNumberOfPlayers) {
        this.maximumNumberOfPlayers = maximumNumberOfPlayers;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getPlayedTimes() {
        return playedTimes;
    }

    public void setPlayedTimes(int playedTimes) {
        this.playedTimes = playedTimes;
    }

    public int getRating() {
        return rating;
    }

    public void setRating(int rating) {
        this.rating = rating;
    }

    public long getId() {
        return id;
    }
    
    @Override
    public boolean equals(Object o){
        if (null != o && o.getClass().equals(getClass())){
            return ((GameTitle) o).getId() == getId();
        }
        return false;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 89 * hash + (int) (this.id ^ (this.id >>> 32));
        return hash;
    }
}
